package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.service.SignService;
import com.esm.serviceimpl.SignServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * GetYrMthEmppSignController_wcj
 * 获取员工选择年、月、日的签到记录控制者
 * @author 魏长均
 *
 */
public class GetYrMthDayEmppSignController_wcj extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	SignService sService = new SignServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		String selectYear = req.getParameter("year");
		String selectMonth = req.getParameter("month");
		String selectDay = req.getParameter("day");
		int uid = Integer.parseInt(req.getParameter("uid"));
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("rows"));
		int total = sService.getEmppYrMthDaySignTotalRows(uid, selectYear, selectMonth, selectDay);
		JSONArray jao = sService.getYrMthDayEmppSign(uid, selectYear, selectMonth, selectDay, page, pageSize);
		
		JSONObject  jo = new JSONObject();
		PrintWriter pw = resp.getWriter();
		jo.put("total", total);
		jo.put("rows", jao);
		PrintWriterUtil.flushJoAndClosePrintWriter(pw, jo);
	}
}
